package com.android.pindaojia.utils;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.android.pindaojia.activity.BaseObject;
import com.android.pindaojia.pojo.JumpKeFuUintPojo;
import com.android.pindaojia.pojo.WidthHeighGlidePojo;


/**
 * Created by Administrator on 2017/11/14.
 */

public class CommonUtils {

    public static void JumpToKeFu(Context mcontext,JumpKeFuUintPojo pojo){
        Intent intents = new Intent(mcontext,BaseObject.class);
        intents.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE,"客服");

        String kf_online =  pojo.kf_online;
        String bid =  pojo.bid;
        String goods_id =  pojo.goods_id;
        if(kf_online==null) {
            String url =ConstantsUrl.basedomain+"chat?good_id=" + goods_id ;
//            String url =ConstantsUrl.basedomain+"chat?";
//            if (goods_id != null && "".equals(goods_id)) {
//
//                url+="good_id=" + goods_id ;
//            }

            if (bid != null && !bid.equals("")) {
                url+="&bid=" + bid;
                //  intents.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_WEB_URL, "http://ptmore1.lnest.cc/chat?good_id=" + goods_id + "&bid=" + bid);
            } else {
                //   intents.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_WEB_URL, "http://ptmore1.lnest.cc/chat?good_id=" + goods_id);
            }
            intents.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_WEB_URL, url);

            ReleaseManager.printLog("bottom_contact",url);
        }
        else {
            intents.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_WEB_URL,pojo.kf_online);
        }
        mcontext.startActivity(intents);
    }

    /**
     *
     * @param list_type 0表示一个的 1表示两个的?
     * @return
     */
    public static boolean  CheckLayoutStyle(int list_type){
        if(list_type==0){
            return true;
        }
        return false;
    }

    public static void SetViewWidthH(WidthHeighGlidePojo pojo, View view){
        ViewGroup.LayoutParams layoutParams=    view.getLayoutParams();
        if(pojo.type==1){
            layoutParams.width = pojo.width;
            layoutParams.height = pojo.width*1;
            ImageView  imageView = (ImageView)view;
            imageView.setLayoutParams(layoutParams);
        }else  if(pojo.type==11){
            //1:1
            layoutParams.width = pojo.width;
            layoutParams.height = (pojo.width*1);
            view.setLayoutParams(layoutParams);
        }else  if(pojo.type==2){
            //750:330
            layoutParams.width = pojo.width;
            layoutParams.height = (pojo.width*330)/750;
            view.setLayoutParams(layoutParams);
        }else  if(pojo.type==3){
            //750:330
            layoutParams.width = pojo.width;
            layoutParams.height = (pojo.width*330)/750;
            ImageView  imageView = (ImageView)view;
            imageView.setLayoutParams(layoutParams);
        }else  if(pojo.type==5){
            //1:1
            layoutParams.width = pojo.width;
            layoutParams.height = (pojo.width*1)/1;
            view.setLayoutParams(layoutParams);
        }
//        switch (pojo.type){
//            case 1:
//                layoutParams.width = pojo.width;
//                layoutParams.height = pojo.width*1;
//                ImageView  imageView = (ImageView)view;
//                imageView.setLayoutParams(layoutParams);
//                break;
//            case 2:
//                //750:330
//                layoutParams.width = pojo.width;
//                layoutParams.height = (pojo.width*330)/750;
//                view.setLayoutParams(layoutParams);
//                break;
//            case 3:
//                //750:330
//                layoutParams.width = pojo.width;
//                layoutParams.height = (pojo.width*330)/750;
//                ImageView  imageView = (ImageView)view;
//                imageView.setLayoutParams(layoutParams);
//                break;
//        }

    }

}
